YOLO Custom Object Detection

YOLO: You Only Look Once is an object detection network. It localizes and classifies an object. It does both these tasks in a single step. The backbone of YOLO in the darknet-53 neural network, there are 53 convolutional layers in the network for feature extraction.

Connecting to Google Drive, where we have all our Files

Let's check for the cv2 version colab is using

We already have our folders ready let's have a look at them

Darknet is an open-source neural network written by Joseph Redmon. It is written in C and CUDA. It supports both CPU and GPU computation. The official implementation of the darknet is available at: https://pjreddie.com/darknet/ . We will use a slightly modified version of the darknet available at AlexyAB/darknet. This neural network framework can be used for object detection using YOLO.

Change the current directory using %cd. We should be in darknet folder

Compiling the Model

Next step involves creating label files and creating train and test images

Luckily we already have python scripts to create our three files which are labels, train and text

We will now load a pre trained model and make changes to it to be used in training

Downloading darknet53.conv.74

Let's now move to our home folder, to be ready for training

Before traing let's be sure we have the darknet function working and GPU running

Training

Everything looks fine! Let's start the training now..!

we just need labelled_data, darknet53.conv.74 and yolov3_custom.cfg which is the configuration file and we are all set for training

Finally, we have a trained model saved in the backup folder we created, let's move the back up folder and test few images

Testing

We will first pass a single image and see the output

Our model has done a great job, we can now pass multipl images and get the bounding boxes for them as well

The model works perfectly on all the images provided, we can now also test it on a video file

Again the results are amazing the model could easily find a tree in the video and create a bounding box around it

END